<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<style>
    .tishi_biao{color: #FEA918!important;cursor: pointer;position: relative;right: 7px;top: -35px;float: right}
    .tishi_hui{margin-left: 20px}
    .tishi_an{margin-left: 20px}
</style>

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">


        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" id="title" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <span class="tishi_biao colorhuang" onclick="tishi_biao()">标题格式提示</span>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>汇报类型</label>
                        <div class="layui-input-block">
                            <div id="huilei"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">关联工作汇报</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="qianid" class="layui-input qianid" onclick="openPage('../public/choose_port.php?dom=qianid&page=port','80%','80%')">
                            <div class="choose_div" id="qianid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_port.php?dom=qianid&page=port','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>汇报日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="huidt" id="huidt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>汇报周期</label>
                        <div class="layui-input-block">
                            <input type="text" name="huizhoudt" id="huizhoudt" placeholder="请选择" clearable  autocomplete="off" readonly class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>安排类型</label>
                        <div class="layui-input-block">
                            <div id="anlei"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>安排周期</label>
                        <div class="layui-input-block">
                            <input type="text" name="anzhoudt" id="anzhoudt" placeholder="请选择" clearable  autocomplete="off" readonly class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>


        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>汇报内容</span><span class="tishi_hui colorhuang" onclick="tishi_hui()">汇报填报提示</span></div>
                        <div>
                            <button type="button" onclick="choose_port_list_an()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">从工作安排选择</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_add_row">插入行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th><text>*</text>原计划事项</th>
                            <th>原计划完成时间</th>
                            <th><text>*</text>完成情况</th>
                            <th><text>*</text>结果描述</th>
                            <th>问题复盘</th>
                            <th>经验总结及改进方案</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="list_list_hui"></tbody>
                    </table>
                    <div class="listerror list_hui">提示：<span></span></div>
                </div>
            </div>
        </div>

        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="2">
                    <div class="opt-btn-group">
                        <div><span>安排内容</span><span class="tishi_an colorhuang" onclick="tishi_an()">安排填报提示</span></div>
                        <div>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_add_row">插入行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th><text>*</text>计划事项</th>
                            <th><text>*</text>计划完成时间</th>
                            <th>风险预判</th>
                            <th>预案制定</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="list_list_an"></tbody>
                    </table>
                    <div class="listerror list_an">提示：<span></span></div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    var param_isturn = getQueryVariable('isturn') || 0;
    if(param_isturn > 0){
        $("#billzhan").remove();
        $("#billtutn").remove();
        $("#billsub").attr('isshen', 1);
    }
    var param_billyushen = getQueryVariable('billyushen') || 0;
    if(param_billyushen == 2){
        $("#billyushen").addClass('layui-hide');
    }

    $("#commentForm").validate({
        rules: {
            title: {required: true},
            huidt: {required: true},
            huizhoudt: {required: true},
            anzhoudt: {required: true},
        },
        messages:{
            title: {required: "请输入"},
            huidt: {required: "请选择"},
            huizhoudt: {required: "请选择"},
            anzhoudt: {required: "请选择"},
        }
    });

    function choose_port_list_an(obj){
        var qianid = get_choose_val('qianid');
        if(!qianid){
            facade.error("请先选择关联工作汇报");return false;
        }
        openPage('../public/choose_port_list_an.php?choose_type=checkox&page=port&portid='+qianid,'80%','80%')
    }




    var pub_wanqing;
    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_edit_port, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                $("#con").val(data.con);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                    if(data.advaners_info.length > 0){
                        tan_tags_init('#advaners', data.advaners_info);
                    }
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                    if(data.nexter_info.length > 0){
                        tan_tags_init('#nexter', data.nexter_info);
                    }
                }
                if(data.flowrelas_info.length > 0){
                    set_choose_btn_more('flowrelas',data.flowrelas_info);
                }


                var qianid_info = res.data.qianid_info;
                if(qianid_info){
                    set_choose_btn('qianid',qianid_info.id,qianid_info.title);
                }


                $("#title").val(data.title);
                $("#huidt").val(data.huidt);
                $("#huizhoudt").val(data.huizhoudt);
                $("#anzhoudt").val(data.anzhoudt);
                $("#explain").val(data.explain);


                xmselect_dan('huilei', res.data.huilei, data.huilei, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#huilei").find('xm-select').removeClass('error');
                    }else{
                        $("#huilei").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('anlei', res.data.anlei, data.huilei, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#anlei").find('xm-select').removeClass('error');
                    }else{
                        $("#anlei").find('xm-select').addClass('error');
                    }
                });


                pub_wanqing = res.data.wanqing;

                var listHuiStr = '';
                listHuiStr += '<tr>';
                listHuiStr += '<td style="width: 45px">1</td>';
                listHuiStr += '<td><input type="text" class="layui-input shi"></td>';
                listHuiStr += '<td><input type="text" class="layui-input wandt bdate_ymd" readonly></td>';
                listHuiStr += '<td><div class="wanqing"></div></td>';
                listHuiStr += '<td><input type="text" class="layui-input miao"></td>';
                listHuiStr += '<td><input type="text" class="layui-input fupan"></td>';
                listHuiStr += '<td><input type="text" class="layui-input gaifang"></td>';
                listHuiStr += '</tr>';
                short_table_opt_func(listHuiStr, 1, {name:'wanqing', data:res.data.wanqing, value:''});

                var list_hui = res.data.list_hui;
                if(list_hui.length > 0){
                    for (var key in list_hui){
                        var str = '';
                        var nums = parseInt(key)+1;
                        str += '<tr>';
                        str += '<td style="width: 45px">'+nums+'</td>';
                        str += '<td><input type="text" class="layui-input shi" value="'+list_hui[key].shi+'"></td>';
                        str += '<td><input type="text" class="layui-input wandt bdate_ymd" value="'+list_hui[key].wandt+'" readonly></td>';
                        str += '<td><div class="wanqing wanqing'+nums+'" key="'+nums+'"></div></td>';
                        str += '<td><input type="text" class="layui-input miao" value="'+list_hui[key].miao+'"></td>';
                        str += '<td><input type="text" class="layui-input fupan" value="'+list_hui[key].fupan+'"></td>';
                        str += '<td><input type="text" class="layui-input gaifang" value="'+list_hui[key].gaifang+'"></td>';
                        str += '</tr>';
                        $("#list_list_hui").append(str);
                        xmselect_list_dan('wanqing'+nums, res.data.wanqing, list_hui[key].wanqing);
                    }
                }






                var listAnStr = '';
                listAnStr += '<tr>';
                listAnStr += '<td style="width: 45px">1</td>';
                listAnStr += '<td><input type="text" class="layui-input shi"></td>';
                listAnStr += '<td><input type="text" class="layui-input wandt bdate_ymd" readonly></td>';
                listAnStr += '<td><input type="text" class="layui-input fengpan"></td>';
                listAnStr += '<td><input type="text" class="layui-input yuzhi"></td>';
                listAnStr += '</tr>';
                short_table_opt_func(listAnStr, 2);

                var list_an = res.data.list_an;
                if(list_an.length > 0){
                    for (var key in list_an){
                        var str = '';
                        var nums = parseInt(key)+1;
                        str += '<tr>';
                        str += '<td style="width: 45px">'+nums+'</td>';
                        str += '<td><input type="text" class="layui-input shi" value="'+list_an[key].shi+'"></td>';
                        str += '<td><input type="text" class="layui-input wandt bdate_ymd" value="'+list_an[key].wandt+'" readonly></td>';
                        str += '<td><input type="text" class="layui-input fengpan" value="'+list_an[key].fengpan+'"></td>';
                        str += '<td><input type="text" class="layui-input yuzhi" value="'+list_an[key].yuzhi+'"></td>';
                        str += '</tr>';
                        $("#list_list_an").append(str);
                    }
                }





                update_refresh_row_func();

                public_upload_file_load('upload_files', res.data.files);
                render_from();
                initParseMoney();
            }
        });


        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');


            data.field.qianid = get_choose_val('qianid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                if(!data.field.huilei){
                    $("#huilei").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#huilei").find('xm-select').removeClass('error');
                }

                if(!data.field.anlei){
                    $("#anlei").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#anlei").find('xm-select').removeClass('error');
                }

                if(!validRes){return false;}
            }



            var list_hui = [''];
            try {
                $('#list_list_hui tr').each(function (i) {
                    var shi = $(this).find('.shi').val();
                    var wandt = $(this).find('.wandt').val();
                    var wanqing = $(this).find('.wanqing').find('input').val();
                    var miao = $(this).find('.miao').val();
                    var fupan = $(this).find('.fupan').val();
                    var gaifang = $(this).find('.gaifang').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!shi){
                            throw new Error('第'+index+'行，请输入原计划事项');
                        }
                        if(!wanqing){
                            throw new Error('第'+index+'行，请选择完成情况');
                        }
                        if(!miao){
                            throw new Error('第'+index+'行，请输入结果描述');
                        }
                    }

                    list_hui.push({
                        shi:shi,
                        wandt:wandt,
                        wanqing:wanqing,
                        miao:miao,
                        fupan:fupan,
                        gaifang:gaifang,
                    });
                });
            } catch(e) {
                $(".listerror list_hui").find('span').text(e.message);
                $(".listerror list_hui").show();
                return false;
            }
            $(".listerror list_hui").hide();
            data.field.list_hui = list_hui;


            var list_an = [''];
            try {
                $('#list_list_an tr').each(function (i) {
                    var shi = $(this).find('.shi').val();
                    var wandt = $(this).find('.wandt').val();
                    var fengpan = $(this).find('.fengpan').val();
                    var yuzhi = $(this).find('.yuzhi').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!shi){
                            throw new Error('第'+index+'行，请输入计划事项');
                        }
                        if(!wandt){
                            throw new Error('第'+index+'行，请选择计划完成时间');
                        }
                    }

                    list_an.push({
                        shi:shi,
                        wandt:wandt,
                        fengpan:fengpan,
                        yuzhi:yuzhi,
                    });
                });
            } catch(e) {
                $(".list_an").find('span').text(e.message);
                $(".list_an").show();
                return false;
            }
            $(".list_an").hide();
            data.field.list_an = list_an;



            data.field.id = param_id;
            data = parseMoney(data);
            data.field.files = public_upload_file_value('upload_files');
            public_flow_submit(data.field, ask_flowdata_add_port, ask_flowdata_edit_port, $(this).attr('but'));
            return false;
        });

    });


    function tishi_biao(){
        var str = '';
        str += '<span>示例：</span></br>';
        str += '<span>2024年5月22-24日周三小复盘及5月25-26日工作安排</span></br>';
        str += '<span>2024年5月第一周周复盘及5月第二周周工作安排</span></br>';
        str += '<span>2024年5月月复盘及6月月工作安排</span></br>';
        layer.confirm("<div class='tit'>标题格式说明：</div><div class='exp' style='padding-top:20px'>"+str+"</div>", {
                title:'提示',
                icon: 3,
                area:['800px','450px'],
                btn:['取消']
            }, function(conindex){
                layer.close(conindex);
            }
        )
    }
    function tishi_hui(){
        var str = '';
        str += '<table class="layui-table" lay-size="sm">';
        str += '<tbody class="short_table_tbody" id="list_list_an">';
        str += '<tr><th rowspan="6" style="width: 100px">目的</th></tr>';
        str += '<tr><td>1.明确复盘对魚:明确要复盘工作的县体内容、时间、重点以及要达到的效果等，以便有针对性地开展复盘;</td></tr>';
        str += '<tr><td>2.梳理全过程:发现或提出过程中存在的问题;</td></tr>';
        str += '<tr><td>3.分析问题，找出原因:对工作中出现的各种问题进行分析，进而找出问题的根本原因;</td></tr>';
        str += '<tr><td>4.制定改进方案，并对改进方案进行跟进:根据问题分析的原因，制定相应的、具体的改进措施，并对该措施的实施过程进行调整与优化，以确保该措施效果的实现;</td></tr>';
        str += '<tr><td>5.汲取教训、总结经验:对复盘的整个过程进行反思与总结，并提炼成方法论与规律，为以后工作提供参考与借鉴。</td></tr>';

        str += '<tr><th rowspan="5">原则</th></tr>';
        str += '<tr><td>1.开放与空杯心态:摒弃自我意识，兼听不同意见，发现深层次原因;</td></tr>';
        str += '<tr><td>2.坦诚与信任表达:敢于接受不利后果与事情真相;</td></tr>';
        str += '<tr><td>3.客观与实事求是:探清事情失败与成功的主客观原因，偶必然因素;</td></tr>';
        str += '<tr><td>4.批评与自我批评:深刻反思，否定自我。</td></tr>';

        str += '<tr><th rowspan="3">要求</th></tr>';
        str += '<tr><td>1.不是追究责任、开批判会;不是强调客观、推卸责任;</td></tr>';
        str += '<tr><td>2.是求真:实事求是;求实:内容与找原因;求学:改进与提高;求内:反思与自我剖析;求道:探寻本质与总结规律;求优:优化流程与简化方式。</td></tr>';

        str += '</tbody>';
        str += ' </table>';

        layer.confirm("<div class='tit'>汇报填报提示：</div><div class='exp' style='padding-top:20px'>"+str+"</div>", {
                title:'提示',
                icon: 3,
                area:['1000px','650px'],
                btn:['取消']
            }, function(conindex){
                layer.close(conindex);
            }
        )
    }
    function tishi_an(){
        var str = '';
        str += '<table class="layui-table" lay-size="sm">';
        str += '<tbody class="short_table_tbody" id="list_list_an">';
        str += '<tr><th rowspan="5" style="width: 100px">目的</th></tr>';
        str += '<tr><td>1.明确具体工作内容:工作内容必须是具体的、可以衡星的、可以达到的、有明确载止期限的，且与其他具体工作具有关联性;</td></tr>';
        str += '<tr><td>2.预见性风险预判:对可能出现的不利情况、可能存在的风险进行预判;</td></tr>';
        str += '<tr><td>3.预见性的制定科学预案:根据工作中可能会出现的困难、障碍、偏差、缺点等，制定明确的县体办法与措施，避免发生问题时陷于被动;</td></tr>';
        str += '<tr><td>4.过程及时做动态优化与调整:在工作执行过程中，应不断对过程进行检察和跟进，及时优化与调整。</td></tr>';

        str += '<tr><th rowspan="6">原则</th></tr>';
        str += '<tr><td>1.局部服从全局:全局利益为重，反对本位主义;</td></tr>';
        str += '<tr><td>2.切实可行:从实际情况出发明确县体目标、任务与标准;</td></tr>';
        str += '<tr><td>3.集思广益:汇集多方意见，反对主观臆断、反对独断专行、反对闭门造车;</td></tr>';
        str += '<tr><td>4.突出重点;理清轻重缓急，突出重点，不能以点盖面、以偏概全、芝麻西瓜一把抓;</td></tr>';
        str += '<tr><td>5.防患于未然:对未来可能发生的“意外”，必须有预防性与解决性措施。</td></tr>';

        str += '<tr><th rowspan="5">要求</th></tr>';
        str += '<tr><td>1.工作安排不是写出来的，而是做出来的;</td></tr>';
        str += '<tr><td>2.工作安排的内容远比形式重要，要拒绝形式主义;</td></tr>';
        str += '<tr><td>3.工作安排要求简明扼要、具体明确、用词造句力求精准，不可含糊其辞;</td></tr>';
        str += '<tr><td>4.工作安排应具有极强的预见性、操作性、针对性、时效性、有序性、落地性等。</td></tr>';

        str += '</tbody>';
        str += ' </table>';

        layer.confirm("<div class='tit'>安排填报提示：</div><div class='exp' style='padding-top:20px'>"+str+"</div>", {
                title:'提示',
                icon: 3,
                area:['1000px','650px'],
                btn:['取消']
            }, function(conindex){
                layer.close(conindex);
            }
        )
    }

</script>
</body>
</html>
